package com.wlyuan.open.scanner.utils.enums;

import com.wlyuan.core.marker.NamedValue;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author lijing
 * @description 线上承运商状态新老系统对应关系，老系统由invalid和status确定
 */
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
@Getter
public enum SupplierInvalidEnum implements NamedValue<Integer> {

    //已通过
    INVALID_PASS(1L, 0, 1, "已通过"),
    //禁用
    INVALID_NO(1L, 1, 0, "禁用"),
    INVALID_NO_ZERO(0L, 1, 0, "禁用"),
    //待审核
    INVALID_WAIT(0L, 0, 2, "待审核"),
    //拒绝
    INVALID_TO_PASS(2L, 0, 4, "拒绝"),
    INVALID_TO_PASS_REJ(2L, 1, 4, "拒绝"),

    //待审核
    INVALID_TO_WAIT(10L, 0, 2, "待审核"),
    ;

    private final Long status;
    private final Integer invalid;
    private final Integer value;
    private final String name;


    private static final Map<String, SupplierInvalidEnum> MAP = new ConcurrentHashMap<>();

    public static SupplierInvalidEnum fromValue(Long status, Integer invalid) {
        return MAP.get(status + ":" + invalid);
    }


    static {
        SupplierInvalidEnum[] supplierInvalidEnum = SupplierInvalidEnum.values();
        for (SupplierInvalidEnum invalid : supplierInvalidEnum) {
            MAP.put(invalid.getStatus() + ":" + invalid.getInvalid(), invalid);
        }
    }

}
